module(..., package.seeall)
--- 模块功能：系统启机门锁状态反馈
-- @author zhangfenghe
-- @module access_control_system.doorLocStatSysStart
-- @license MIT
-- @copyright openLuat
-- @release 2024.05.30
require "sys"
require "mqtt"
require "misc"
require "nvm"
require "config"
require "mqttHostOutMsg"
require "displayLogic"
require "utilsACS"
-- 初始化配置文件
nvm.init("config.lua", true)
-- 获取配置文件信息
local slaveNo, hostNo,openDoorDisplay = nvm.get("ClientNo"), nvm.get("HostNo"),nvm.get("OpenDoorDisplay")
local topic, sendMsg = "", ""
local function doorLocStatSysStart()
    log.info("openDoorDisplay",openDoorDisplay)
    if openDoorDisplay then
        if displayLogic.TimeId then displayLogic.NomalTask() end
        displayLogic.OpenDisplay()
        topic = "acs/" .. hostNo
        log.info("hostNo:",hostNo)
        sendMsg = "{\"action\":\"info\",\"slaveNo\":\"" .. slaveNo ..
                      "\",\"status\":\"1\"}"
        mqttHostOutMsg.InsertHostMsg(topic, sendMsg, 0)
    else
        if not displayLogic.TimeId then displayLogic.NomalTask() end
        if utilsACS.EmerInterruptFlag then
            displayLogic.OpenDisplayCancel()
        end
        topic = "acs/" .. hostNo
        sendMsg = "{\"action\":\"info\",\"slaveNo\":\"" .. slaveNo ..
                      "\",\"status\":\"0\"}"
        mqttHostOutMsg.InsertHostMsg(topic, sendMsg, 0)
    end
end
sys.taskInit(doorLocStatSysStart)
